{extend name="public/base"/}
{block name="body"}
<div class="main-box no-header clearfix">
	<header class="main-box-header clearfix">
		<div class="pull-left">
			<h2>{$meta_title}（{$count}）</h2>
		</div>
		<div class="pull-right">
			<a href="{:url('addsub', ['ydtype'=>1])}" class="btn btn-primary "> 新增</a>
			{eq name="$Request.action" value="alreadyindexstraight"}<button class="btn btn-success list_sort" url="{:url('othersort','','')}">排序</button>{/eq}
		</div>
	</header>
	<div class="main-box-body clearfix">
		<div class="table-responsive">
			<form method="get">
				<div class="col-sm-12 col-md-4 col-lg-3">
					<input type="text" class="form-control" name="keyword" value="" placeholder="请输入关键字">
				</div>
								<div class="col-sm-12 col-md-4">
					<button class="btn btn-primary" type="submit">搜索</button>
				</div>
			</form>
		</div>
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th width="30"><input class="checkbox check-all" type="checkbox"></th>
            <th width="60">ID</th>
            <th>商品图片</th>
            <th>标题</th>
						  <th>类型</th>
            <th>商家</th>
            <th>介绍</th>
            <th>更新时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          {volist name="list" id="item"}
          <tr>
            <td><input class="ids row-selected" type="checkbox" name="ids[]" value="{$item['id']}"></td>
            <td>{$item['id']}</td>
            <td><img src="{$item['cover_id']|get_cover='path'}" width="96" height="50" /></td>
            <td>{$item['good_name']} <br /><br />
											{volist name="$item['goodsrule']" id="vo" }
													<p>规格：{$vo[rule_name]} 价格：{$vo[rule_price]}元 库存：{$vo[stock] >10 ? $vo[stock] : $vo[stock].'<span style="font-size: 16px;color: red;">(库存不足！)</span>'} </p>
											{/volist}
						</td>
						<td>

							{eq name="$item.yd_type" value="1"}产地直发{else /}配送{/eq}
						</td>
            <td>{$item['shop_id']|get_table_field="id","shopname","goodshops"}</td>
						<td>{$item['good_brief']|msubstr=###,0,10}</td>
						<td>{$item['update_time']}</td>

            <td>
              <a href="{:url('editsub',array('id'=>$item['id']))}">编辑</a>
							{eq name="$item.status" value="-1"}<a href="{:url('editStatus',array('id'=>$item['id'], 'status'=>1))}" class="confirm ajax-get">上架</a>{/eq}
							{eq name="$item.status" value="1"}<a href="{:url('editStatus',array('id'=>$item['id'], 'status'=>-1))}" class="confirm ajax-get">下架</a>{/eq}
              <a href="{:url('del',array('id'=>$item['id']))}" class="confirm ajax-get">删除</a>
            </td>
          </tr>
          {/volist}
        </tbody>
      </table>
				{$list->render()}
		</div>
	</div>
</div>
{/block}

{block name="script"}

<script type="text/javascript">
$(function() {
	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});

});
</script>
{/block}
